//
//  StrategyDetailCell.m
//  XhlTrip
//
//  Created by dllo on 15/8/24.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "StrategyDetailCell.h"
#import "StrategyModel.h"
#import "UIImageView+WebCache.h"

@implementation StrategyDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.cellImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.cellImage];
        [_cellImage release];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.cellImage addSubview:self.nameLabel];
        [_nameLabel release];
        
        self.EnLabel = [[UILabel alloc] init];
        [self.cellImage addSubview:self.EnLabel];
        [_EnLabel release];
        
        self.planButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.planButton setTitle:@"行程" forState:UIControlStateNormal];
        [self.contentView addSubview:self.planButton];
        self.planButton.titleLabel.font = [UIFont systemFontOfSize:16 * Width];
        [self.planButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.tripButton = [UIButton buttonWithType: UIButtonTypeSystem];
        [self.tripButton setTitle:@"旅行地" forState:UIControlStateNormal];
        [self.contentView addSubview:self.tripButton];
        self.tripButton.titleLabel.font = [UIFont systemFontOfSize:16 * Width];
        [self.tripButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.topicButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.topicButton setTitle:@"专题" forState:UIControlStateNormal];
        [self.contentView addSubview:self.topicButton];
        self.topicButton.titleLabel.font = [UIFont systemFontOfSize:16 * Width];
        [self.topicButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.planImage = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.planImage setBackgroundImage:[self nameWithPath:@"fff.png"] forState:UIControlStateNormal];
        [self.contentView addSubview:self.planImage];
    
        
        self.tripImage = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.tripImage setBackgroundImage:[self nameWithPath:@"trip.png"] forState:UIControlStateNormal];
        [self.contentView addSubview:self.tripImage];
        
        self.topicImage = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.topicImage setBackgroundImage:[self nameWithPath:@"topic.png"] forState:UIControlStateNormal];
        [self.contentView addSubview:self.topicImage];
        
        
        _nameLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:19 * Width];
        _EnLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:15 * Width];
        
        
       
        _EnLabel.textColor = [UIColor whiteColor];
        _nameLabel.textColor = [UIColor whiteColor];
     

        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.cellImage.frame = CGRectMake(10 * Width, 10 * Height, self.contentView.frame.size.width - 20 * Width, self.contentView.frame.size.height - 100 * Height);
    
    self.nameLabel.frame = CGRectMake(10 * Width, 10 * Height, 200 * Width, 30 * Height);
    self.EnLabel.frame = CGRectMake(50 * Width, 40 * Height, 130 * Width, 30 * Height);
   
    self.planButton.frame = CGRectMake(55 * Width, self.contentView.frame.size.height - 45 * Height, 50 * Width, 50 * Height);
    self.tripButton.frame = CGRectMake(160 * Width, self.contentView.frame.size.height - 45 * Height, 50 * Width, 50 * Height);
    self.topicButton.frame = CGRectMake(265 * Width, self.contentView.frame.size.height - 45 * Height, 50 * Width, 50 * Height);
    
    self.planImage.frame = CGRectMake(60 * Width, self.contentView.frame.size.height - 80 * Height, 40 * Width, 40 * Height);
    self.tripImage.frame = CGRectMake(165 * Width, self.contentView.frame.size.height - 80 * Height, 40 * Width, 40 * Height);
    self.topicImage.frame = CGRectMake(265 * Width, self.contentView.frame.size.height - 80 * Height, 45 * Width, 45 * Height);


    
}

- (void)setStrDetModel:(StrategyModel *)strDetModel
{
    if (_strDetModel != strDetModel) {
        [_strDetModel release];
        _strDetModel = [strDetModel retain];
    }
    self.nameLabel.text = strDetModel.name_zh_cn;
    self.EnLabel.text = strDetModel.name_en;
    [self.cellImage sd_setImageWithURL:strDetModel.image_url];
}

- (UIImage *)nameWithPath:(NSString *)paths
{
    NSString *path = [[NSBundle mainBundle] pathForResource:paths ofType:nil];
    UIImage *image = [UIImage imageWithContentsOfFile:path];
    return image;
}


- (void)dealloc
{
    [_topicImage release];
    [_tripImage release];
    [_planImage release];
    [_topicButton release];
    [_planButton release];
    [_tripButton release];
    [_nameLabel release];
    [_EnLabel release];
    [_strDetModel release];
    [_cellImage release];
    [super dealloc];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
